package com.chanyachting.emall.action.yellow;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.Action;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import com.chanyachting.emall.domain.Company;
import com.chanyachting.emall.form.CompanyForm;
import com.chanyachting.emall.serviceImpl.CompanyServiceImpl;

public class ReadCompanyAction  extends Action {
	public ActionForward execute(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
			throws Exception {
		
		String companyId = request.getParameter("comanyId");
		CompanyServiceImpl naservice = new CompanyServiceImpl();
		CompanyForm cForm = (CompanyForm)form;
		List companyList = null;
		Company company = null;
		if(null != companyId && !"".equals(companyId)){
			companyList = naservice.getCompanyById(companyId +"");	
		}
		
		if(null != companyList && companyList.size()>0){
			company = (Company)companyList.get(0);
		}
		System.out.println(company.getCompanySummary());
		cForm.setComp(company);
		return mapping.findForward("readCompany");
	}
}
